<!--河南星辰软件科技有限公司
@copyright Copyright (c) 2010~2022 All rights reserved.
-->
<template>
  <div class='app-container'>
    <el-row>
      <el-col :span='22' :xs='24'>
        <el-form ref="form" :model="pro_list" :rules="rules" label-width="100px" id="mvcfm">
          <el-button @click="productTechUpSubmit('')" type='success' size="mini"><i class='fa fa-check'></i>修改</el-button>
          <el-button @click="gotoPage('/mes/product/ProductTechDet?'+vueparams+'')" type='primary' size="mini"><i class='fa fa-reply'></i>返回</el-button>
          <div class="form-unit">
            <span class="mvc-title-left"> 工艺管理器 </span>
          </div>
          <div>
            <el-row>
              <el-col :span="12">
                <el-form-item label="范围类别" prop="tech_type">
                  <el-select style='width:100%' v-model="pro_list.tech_type">
                    <el-option label="－－无－－" value='' />
                    <el-option v-for="dict in s_type" :key="dict.__code" :label="dict.__desc" :value="dict.__code"></el-option>
                  </el-select>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="24">
                <el-form-item label="产品类别" prop="category_id">
                  {{pro_list.category_id}}
                  <el-button @click="popProductClassTech('category_id','category_id')" type="success" size="mini"><i class="fa fa-edit"></i>选择</el-button>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="范围名称" prop="tech_name">
                  <el-input v-model="pro_list.tech_name" />
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="24">
                <el-form-item label="标准文件编号" prop="tech_fileid">
                  {{pro_list.tech_fileid}}
                  <el-button @click="popSelectionStandardFile('tech_fileid','tech_fileid')" type="success" size="mini"><i class="fa fa-edit"></i>选择</el-button>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="检测范围状态" prop="tech_state">
                  <el-select style='width:100%' v-model="pro_list.tech_state">
                    <el-option label="启用" value="1" />
                    <el-option label="禁用" value="0" />
                  </el-select>
                </el-form-item>
              </el-col>
            </el-row>
          </div>
        </el-form>
      </el-col>
      <el-col :span='2' :xs='24'>
        <el-menu default-active='active' class='menu-unit'>
          <el-menu-item v-for='item in Container'>
            <el-link @click="gotoMenu(item.url)" :type="'范围明细'===item.name?'primary':'default'">{{item.page_desc||item.name}}</el-link>
          </el-menu-item>
        </el-menu>
      </el-col>
    </el-row>
    <el-dialog :visible.sync="ProductClassTechVisible" append-to-body>
      <ProductClassTech v-if="ProductClassTechVisible" ref="ProductClassTech" :popparams="popparams"> </ProductClassTech>
    </el-dialog>
    <el-dialog :visible.sync="SelectionStandardFileVisible" append-to-body>
      <SelectionStandardFile v-if="SelectionStandardFileVisible" ref="SelectionStandardFile" :popparams="popparams"> </SelectionStandardFile>
    </el-dialog>
  </div>
</template>
<script>
  import request from '@/utils/request'
  import ProductClassTech from "@/views/mes/product/ProductClassTech";
  import SelectionStandardFile from "@/views/mes/product/SelectionStandardFile";
  export default {
    name: 'ProductTechUp',
    components: {
      ProductClassTech,
      SelectionStandardFile,
    },
    props: ['popparams'],
    data() {
      return {
        ProductClassTechVisible: false,
        ProductClassTechValue: null,
        ProductClassTechDesc: null,
        SelectionStandardFileVisible: false,
        SelectionStandardFileValue: null,
        SelectionStandardFileDesc: null,
        vueparams: this.getVUEParams(""),
        pro_list: {
          tech_type: null,
          category_id: null,
          tech_name: null,
          tech_fileid: null,
          tech_state: null,
        },
        s_type: [],
        loading: false,
        Container: null,
        rules: {
          tech_type: [{
            required: true,
            message: "范围类别不能为空",
            trigger: 'blur',
          }],
          category_id: [{
            required: true,
            message: "产品类别不能为空",
            trigger: 'change',
          }],
          tech_fileid: [{
            required: true,
            message: "标准文件编号不能为空",
            trigger: 'change',
          }],
        }
      }
    },
    created() {
      this.getData();
      this.loadContainerMenu({
        pid: "28847805EE1D403DBCD43478FD18BD08",
        name: "检测范围右菜单",
        selected: "范围明细"
      }, 'Container', this.vueparams);
    },
    updated() {},
    mounted() {},
    methods: {
      getData() {
        request({
          method: 'get',
          url: '/xcapi/VUEAction/mes/product/TechnologyAction/productTechUp?' + this.vueparams,
        }).then(data => {
          for (var k in data) {
            if (Array.isArray(data[k])) {
              this[k] = data[k];
            } else {
              $.extend(this[k], data[k]);
            }
          }
        })
      },
      productTechUpSubmit(_params) {
        this.$refs["form"].validate(valid => {
          if (valid) {
            request({
              method: 'post',
              url: '/xcapi/VUEAction/mes/product/TechnologyAction/productTechUpSubmit?' + _params + this.vueparams,
              data: this.postData()
            }).then(data => {
              this.gotoPage("/mes/product/ProductTechDet/productTechDet?" + this.vueparams, data);
              this.msgSuccess(data.msg);
            })
          } else {
            this.msgError("必填项错误");
          }
        });
      },
      popProductClassTech(desc, value) {
        this.ProductClassTechVisible = true;
        this.ProductClassTechDesc = desc;
        this.ProductClassTechValue = value;
      },
      closeProductClassTech(value, desc) {
        this.ProductClassTechVisible = false;
        this.$set(this.pro_list, this.ProductClassTechDesc, desc);
        this.$set(this.pro_list, this.ProductClassTechValue, value);
      },
      popSelectionStandardFile(desc, value) {
        this.SelectionStandardFileVisible = true;
        this.SelectionStandardFileDesc = desc;
        this.SelectionStandardFileValue = value;
      },
      closeSelectionStandardFile(value, desc) {
        this.SelectionStandardFileVisible = false;
        this.$set(this.pro_list, this.SelectionStandardFileDesc, desc);
        this.$set(this.pro_list, this.SelectionStandardFileValue, value);
      },
    },
  }
</script>
